define(
		[ "PDAppDir/properties", "PDUtilDir/util", "PDUtilDir/tool", "PDUtilDir/slidebar",
				"PDUtilDir/inputSelect",
				"PDUtilDir/fileupload/singleFileUpload", "Date", "DateCN",
				"css!DateCss", "PicView", "css!picViewCss",
				"css!AppPathDir/order/orderDoneInfos/views/css/css" ],
		function(Properties, Util, Tool, Slidebar, inputSelect, MFU) {
			function paySupportInit($scope, $compile) {
				return new paySupport($scope, $compile);
			}
			function paySupport($scope, $compile) {
				this.$scope = $scope;
				this.$compile = $compile;
			}
			paySupport.fn = paySupport.prototype;
			paySupport.fn.digest = function() {
				this.$scope.$digest();
			}
			paySupport.fn.init = function(id) {
				this.entity = {
					id: id,
					pays: new Array()
				};
				this.cache = {
					fileServer: Properties.URL_FILE_SERVER_URL,
					images: new Array()
				}
				this.bind = {}
			}
			
			paySupport.fn.run = function(data) {
				var _this = this;
				_this.init(data);
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/order/orderDoneInfos/views/pay.html",
					$scope : this.$scope,
					$compile : this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			paySupport.fn.initialization = function() {
				var _this = this;
				$.ajax({
					url : getServer() + "/flea/hclv/visitor/order/findDetailById.htmls",
					data : {
						model : _this.entity.id
					},
					success : function(data) {
						_this.entity = $.extend(_this.entity, data.data.order);
						_this.entity.statusName = _this.$scope.cache.statusMap.get(_this.entity.status);
						_this.digest();
					}
				});
				
				// 初始化支付类型下拉框
				inputSelect.dropCache();
				inputSelect({
					id : "paymentTypeName",
					key : {
						id : "dictCode",
						name : "dictName",
						data : "data",
					},
					data : _this.$scope.cache.types,
					simpleData : true,
					searchAble : false,
					callback : function(id, obj) {
						_this.bind.payPlatform = id[0];
						_this.bind.paymentName = obj[0].dictName;
						_this.$scope.payOrderForm.paymentType.$setViewValue(_this.bind.payPlatform);
					}
				});
				if(_this.cache.images.length == 0){
					$.ajax({
						url : getServer() + "/flea/hclv/qr/manage/getQrPath.htmls",
						success : function(data) {
							if(data.status == 200){
								_this.cache.images = data.data;
								_this.digest();
							}
						}
					});
				}
			};
			paySupport.fn.add = function() {
				this.entity.pays.push($.extend({},this.bind));
				this.bind = {
					paymentType: this.bind.paymentType,
				    paymentName:  this.bind.paymentName
				};
				this.cache.isOk = true;
				this.$scope.payOrderSaveForm.pays.$setViewValue(this.cache.isOk);
			};
			paySupport.fn.save = function() {
				var _this = this;
				$.ajax({
					url : getServer() + "/flea/hclv/visitor/visitorPay/addPayment.htmls",
					data : {
						'model' : JSON.stringify({
							id : _this.entity.id,
							orderNo : _this.entity.orderNo,
							pays: _this.entity.pays
						})
					},
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.$scope.grid.refresh();
						Util.alert(data.message);
						_this.slidebars.close();
					}
				});
			};
			return paySupportInit;
		});